<?php get_instance()->view('common/header');?>
<link href="<?php echo $this->staticUrl?>video/css/video-js.min.css" rel="stylesheet" type="text/css">
<script src="<?php echo $this->staticUrl?>video/js/video.min.js"></script>
<body>
<div class="bor_tt p3p">
    <div class="hengleft">
        <div class="minuserimg imgbox"><img src="<?php echo $info['portrait']['xs']?>" alt=""></div>
        <div class="">
            <h1><?php echo $info['nickname']?></h1>
            <p class="f07 pjdatatime"><?php echo $info['addtime']?></p>
        </div>
    </div>
    <div class="huifu">
        <p class="m5_0 f09"><?php echo $info['content']?></p>
        <div class="huifuimgbox imgboxpull" style="max-height: 5em;">
            <?php if(!empty($info['image'])): foreach ($info['image'] as $k => $v):?>
                <div class=" imgbox"><img src="<?php echo $v['og']?>" alt=""></div>
            <?php endforeach; endif;?>
            <?php if(!empty($info['video'])): ?>
                <?php if($info['yun_status'] == 2): ?>
               <div class="imgbox">
                    <video 
                       class="video-js vjs-default-skin" controls preload="none" poster="<?php echo $info['coverUrl']?>" style="width:100%;height:100%;">
                        <source src="<?php echo $info['video']?>" type='video/mp4' />
                    </video>
                </div>
                    <?php else:?>
                    <div class=" imgbox"><img src="<?php echo $this->staticUrl?>img/checking.png" alt=""></div>
            <?php endif;?>
            <?php endif;?>
        </div>
        <div class="textEll f08 cor9 heng">
            <div>浏览<?php echo $info['browse_number']?>次
                <a href="" class="cor9 ml10"><?php echo $info['address']?></a>
            </div>
            <div class="vCenter f12">
                <a href="javascript:;" class="mr10 praise">
                    <?php if($info['praise'] == 1):?>
                        <img src="<?php echo $this->staticUrl?>img/png/pic88.png" class="heightimg praise_image" alt="">
                    <?php else:?>
                        <img src="<?php echo $this->staticUrl?>img/png/pic87.png" class="heightimg praise_image" alt="">
                    <?php endif;?>
                </a>
<!--                <a href="javascript:;" class="mr10 collection">-->
<!--                    --><?php //if ($info['is_collection'] == 2):?>
<!--                        <img class="heightimg coll_image" src="--><?php //echo $this->staticUrl?><!--img/png/pic141.png" alt="">-->
<!--                    --><?php //else:?>
<!--                        <img class="heightimg coll_image" src="--><?php //echo $this->staticUrl?><!--img/png/pic141-2.png" alt="">-->
<!--                    --><?php //endif;?>
<!--                </a>-->
                <a href="javascript:;" class="comment"><img class="heightimg" src="<?php echo $this->staticUrl?>img/png/pic103.png" alt=""></a>
            </div>
        </div>
    </div>
</div>
<div class="bor_bb p3p hengleft vCenter praise_list">
    <?php if (!empty($info['praiseList']['list'])):?>
    <div class="textEll hengleft">
        <?php foreach ($info['praiseList']['list'] as $k => $v): ?>
            <div class="minuserimg oh f05"><img src="<?php echo $v['portrait']['xs']?>" alt=""></div>
        <?php endforeach;?>
    </div>
    <p class="f09 cor9">等<?php echo $info['praiseList']['count']?>个人觉得很赞</p>
    <?php endif;?>
</div>
<div class="mb20">
    <?php if (!empty($info['commentList'])): foreach ($info['commentList'] as $k => $v):?>
        <div class="p3 mb10 mt10 bor_bb">
            <div class="hengleft pr">
                <div class="minuserimg imgbox"><img src="<?php echo $v['portrait']['xs']?>" alt=""></div>
                <div class="">
                    <h1><?php echo $v['nickname']?></h1>
                    <p class="f07 pjdatatime"><?php echo $v['addtime']?></p>
                </div>
                <?php if ($type == 1 && empty($v['reply']) && $info['consumer_id'] == $this->userId):?>
                    <div class="huifubtn">
                        <a href="javascript:;" class="reply" data-id="<?php echo $v['id']?>" data-name="<?php echo $v['nickname']?>">
                            <img src="<?php echo $this->staticUrl?>img/png/pic134.png" alt="">
                        </a>
                    </div>
                <?php endif;?>
            </div>
            <div class="huifu">
                <p class="m5_0 f09"><?php echo $v['content']?></p>
            </div>
            <?php if (!empty($v['reply'])):?>
                <div class="huifu">
                    <p class="m5_0 f09">回复
                        <span class="lanzi f10"><?php echo $info['nickname']?>：</span>
                        <?php echo $v['reply']?>
                    </p>
                </div>
            <?php endif;?>
        </div>
    <?php  endforeach; endif;?>
</div>

<form action="<?php echo getUrl('friendsCircle/addComment')?>" id="save-form" method="post" style="display:none;">
    <div class="shopcarbox p3p">
        <div class="zan heng vCenter f11 wp100" style="padding-right:5em;">
            <input type="text" class="wenbenpub wp100 p5 required" placeholder="发表评论" name="content">
        </div>
        <div class="btnbox heng vCenter pos" style="right:0;">
            <input type="hidden" value="" name="comment_id">
            <input type="hidden" value="<?php echo $type?>" name="type">
            <input type="hidden" name="fid" value="<?php echo $info['id']?>">
            <button href="" class="posbotbtn f09 mr5" style="padding:.5em .5em">发送</button>
        </div>
    </div>
</form>
</body>
<script src="<?php echo $this->staticUrl?>js/base.js"></script>
<script type="text/javascript">
    $(function () {
        var addComment = "<?php echo getUrl('friendsCircle/addComment')?>",
            replyComment = "<?php echo getUrl('friendsCircle/replyComment')?>",
            id = "<?php echo $info['id']?>",
            is_collection = "<?php echo $info['is_collection']?>";

        /**
         * 点赞
         */
        $(".praise").click(function () {
            blockUI.show();
            var praise_image,
                type = "<?php echo $type?>";
            $.ajax('<?php echo getUrl('friendsCircle/praise');?>', {
                dataType:'json',
                type:'post',
                data:{fid:id,type:type},
                error:function(){
                    blockUI.hide();
                    show_message({status:0, message:'请求超时'});
                },
                timeout:60000,
                success:function(e,textStatus,jqXHR){
                    blockUI.hide();
                    show_message(e);
                    var html = '<div class="textEll hengleft">';
                    if (e.status == 1) {
                        if (e.data.status == 1){
                            // 未点赞
                            praise_image = '<?php echo $this->staticUrl?>img/png/pic87.png';
                        }else{
                            // 已点赞
                            praise_image = '<?php echo $this->staticUrl?>img/png/pic88.png';
                        }
                        $(".praise_image").attr('src', praise_image);
                        // 点赞人数
                        if (e.data.list.length){
                            $.each(e.data.list, function (key, obj) {
                                html += '<div class="minuserimg oh f05"><img src="'+ obj.portrait['xs'] + '" alt=""></div>';
                            });
                            html += '</div><p class="f09 cor9">等' + e.data.count + '个人觉得很赞</p>';
                        }else{
                            html = '';
                        }
                        $(".praise_list").html(html);
                    }
                }
            });
        });

        /**
         * 添加评论
         * addComment
         */
        $(".comment").click(function () {
            $("#save-form").show();
            $("[name='comment_id']").val('');
            $("[name='content']").focus();
            $("[name='content']").attr('placeholder', '发表评论');
            $("[name='content']").val('');
            $("#save-form").attr('action', addComment);
        });

        /**
         * 回复评论
         * replyComment
         */
        $(".reply").click(function () {
            var id = $(this).attr('data-id');
            var name = $(this).attr('data-name');
            $("[name='comment_id']").val(id);
            $("#save-form").show();
            $("[name='content']").focus();
            $("[name='content']").attr('placeholder', '回复'+name);
            $("[name='content']").val('');
            $("#save-form").attr('action', replyComment);
        });

        $("[name='content']").blur(function () {
            var vl = $("[name='content']").val();
            if (!vl.length) {
                $("#save-form").hide();
                $("[name='content']").attr('placeholder', '回复' + name);
                $("[name='content']").val('');
            }
        });

        $.e_validate.init('#save-form',{saveMessage:'保存中...'});

        /**
         * 点击收藏
         */
        $(".collection").click(function () {
            blockUI.show();
            var id = "<?php echo $info['id']?>",
                coll_image,
                type = "<?php echo $type?>",
                url = '',
                CType = 4;
                if (is_collection == 1){
                    url = '<?php echo getUrl('user/saveCollection');?>';
                }else{
                    url = '<?php echo getUrl('user/rmCollection');?>';
                }
                if (type == 2){
                    CType = 5;
                }
            $.ajax(url, {
                dataType:'json',
                type:'post',
                data:{relation_id:id,type:CType},
                error:function(){
                    blockUI.hide();
                    show_message({status:0, message:'请求超时'});
                },
                timeout:60000,
                success:function(e,textStatus,jqXHR){
                    blockUI.hide();
                    show_message(e);
                    if (e.status == 1) {
                        if (is_collection == 2){
                            // 未收藏
                            coll_image = '<?php echo $this->staticUrl?>img/png/pic141-2.png';
                            is_collection = 1;
                        }else{
                            // 已收藏
                            coll_image = '<?php echo $this->staticUrl?>img/png/pic141.png';
                            is_collection = 2;
                        }
                        $(".coll_image").attr('src', coll_image);
                    }
                }
            });
        });
    })
</script>
</html>